import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router);

export const routes = [
    {
        path: '/feed-back',
        name: 'feed-back',//用户反馈
        component: () => import('@/views/feed-back.vue')
    },
    {
        path: '/help-center',
        name: 'help-center',//帮助中心
        component: () => import('@/views/help-center.vue')
    },
    {
        path: '/message-center',
        name: 'message-center',//消息中心
        component: () => import('@/views/message-center.vue')
    },
    {
        path: '/message-info',
        name: 'message-info',//消息详情
        component: () => import('@/views/message-info.vue')
    },
    {
        path: '/order-details',
        name: 'order-details',//订单详情
        component: () => import('@/views/order-details.vue')
    },
    {
        path: '/loan-contract',
        name: 'loan-contract',//借款合同
        component: () => import('@/views/loan-contract.vue')
    },
    {
        path: '/privacy-protocol',
        name: 'privacy-protocol',//隐私协议
        component: () => import('@/views/privacy-protocol.vue')
    },
    {
        path: '/membership-agreement',
        name: 'membership-agreement',//合作社会员协议
        component: () => import('@/views/membership-agreement.vue')
    },
    {
        path: '/repay-code',
        name: 'RepayCode',//va还款码
        component: () => import('@/views/RepayCode.vue')
    },
    {
        path: '/repay',
        name: 'Repay',//去还款
        component: () => import('@/views/Repay.vue')
    },
]

const router = new Router({
    routes,
    // mode: 'history'
});
const LOGIN_PAGE_NAME = 'login';

router.beforeEach((to, from, next) => {
    if (
        window.sessionStorage["loginInfo"] &&
        window.sessionStorage["loginInfo"] !== "{}"
    ) {
        next();
    } else {

        next();
    }

//     const token = getToken();
//     if (!token) {
//         this.$bridge.goLogin();
//         // next({
//         //     name: LOGIN_PAGE_NAME
//         // })
//     }
});

export default router
